package cz.hackathon.core;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import cz.hackathon.rateit.model.Action;

public class Storage {
	
	private static final String FILE_NAME = "app_state";

	public static void save(Action action) throws IOException {
		FileOutputStream fos = new FileOutputStream(FILE_NAME);
		ObjectOutputStream oos = new ObjectOutputStream(fos);
		oos.writeObject(action);
		fos.close();
	}

	public static Action restore() throws Exception {
		ObjectInputStream is = new ObjectInputStream(new FileInputStream(FILE_NAME));
		Action action = (Action) is.readObject();
		is.close();
		return action;
	}

}
